package com.zz.study.sharding.task;

import com.zz.study.sharding.controller.HifleetAisController;
import com.zz.study.sharding.entity.DtFusdataFlinkSimple;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.List;
import java.util.concurrent.Callable;

/**
 * created by xjx on  2024-01-17 20:50
 */
@Slf4j
public class TrackData2RedisTask implements Runnable {

    private RedisTemplate<String, Object> redisTemplate;

    private List<DtFusdataFlinkSimple> trackDataList;

    private String tableName;

    private String mmsi;

    public TrackData2RedisTask(RedisTemplate<String, Object> redisTemplate, List<DtFusdataFlinkSimple> trackDataList, String tableName, String mmsi) {
        this.redisTemplate = redisTemplate;
        this.trackDataList = trackDataList;
        this.tableName = tableName;
        this.mmsi = mmsi;
    }

    @Override
    public void run() {
        log.error("线程池写入redis======"+HifleetAisController.getKey(tableName,mmsi));
        redisTemplate.opsForList().leftPushAll(HifleetAisController.getKey(tableName,mmsi),trackDataList);
    }
}
